﻿using Renci.iRods.Common;
using System.Collections.Generic;

namespace Renci.iRods.Packets
{
    //#define DataObjInp_PI "str objPath[MAX_NAME_LEN]; int createMode; int openFlags; double offset; double dataSize; int numThreads; int oprType; struct *SpecColl_PI; struct KeyValPair_PI;"
    [Packet("DataObjInp_PI")]
    internal class DataObjectInputPacket : Packet
    {
        private IDictionary<string, string> _keyValues = new Dictionary<string, string>();

        [PacketField("objPath", 0, DataTypes.String, 1024)]
        public string Path { get; private set; }

        [PacketField("createMode", 1, DataTypes.Int)]
        public int CreateMode { get; set; }

        [PacketField("openFlags", 2, DataTypes.Int)]
        public int OpenFlag { get; set; }

        [PacketField("offset", 3, DataTypes.Double)]
        public double Offset { get; set; }

        [PacketField("dataSize", 4, DataTypes.Double)]
        public double DataSize { get; set; }

        [PacketField("numThreads", 5, DataTypes.Int)]
        public int NumOfThreads { get; set; }

        [PacketField("oprType", 6, DataTypes.Int)]
        public OperationTypes OperationType { get; set; }

        [PacketField("SpecColl_PI", 7, DataTypes.Packet)]
        public SpecialCollectionPacket SpecialCollection { get; set; }

        [PacketField("KeyValPair_PI", 8, DataTypes.Packet)]
        public KeyValuePairPacket KeyValues
        {
            get
            {
                return new KeyValuePairPacket(this._keyValues);
            }
        }

        public DataObjectInputPacket()
        {
        }

        public DataObjectInputPacket(string path)
            : this()
        {
            this.Path = path;
        }


        public void AddKey(string key)
        {
            this.AddKey(key, string.Empty);
        }

        public void AddKey(string key, string value)
        {
            this._keyValues.Add(key, value);
        }

        //ALL_KW, 		/* operation done on all replica */
        //COPIES_KW, 		/* the number of copies */
        //EXEC_LOCALLY_KW, 	/* execute locally */
        //FORCE_FLAG_KW, 		/* force update */
        //CLI_IN_SVR_FIREWALL_KW, /* client behind same firewall */ 
        //REG_CHKSUM_KW, 		/* register checksum */
        //VERIFY_CHKSUM_KW, 	/* verify checksum */
        //OBJ_PATH_KW,		/* logical path of the object */ 
        //RESC_NAME_KW,		/* resource name */
        //DEST_RESC_NAME_KW,	/* destination resource name */
        //BACKUP_RESC_NAME_KW,	/* destination resource name */
        //DATA_TYPE_KW,		/* data type */
        //DATA_SIZE_KW,
        //CHKSUM_KW,
        //VERSION_KW,
        //FILE_PATH_KW,		/* the physical file path */
        //REPL_NUM_KW,		/* replica number */
        //REPL_STATUS_KW, 	/* status of the replica */
        //DATA_INCLUDED_KW,	/* data included in the input bytes buffer */
        //DATA_OWNER_KW,	
        //DATA_OWNER_ZONE_KW, 
        //DATA_EXPIRY_KW,
        //DATA_COMMENTS_KW,
        //DATA_CREATE_KW,
        //DATA_MODIFY_KW,
        //DATA_ACCESS_KW,
        //DATA_ACCESS_INX_KW,
        //NO_OPEN_FLAG_KW,
        //STREAMING_KW,
        //DATA_ID_KW,
        //COLL_ID_KW,
        //RESC_GROUP_NAME_KW,
        //STATUS_STRING_KW,
        //DATA_MAP_ID_KW,

        //#define ALL_KW 		"all" 		/* operation done on all replica */
        //#define COPIES_KW	"copies" 	/* the number of copies */
        //#define EXEC_LOCALLY_KW	"execLocally" 	/* execute locally */
        //#define FORCE_FLAG_KW 	"forceFlag" 	/* force update */
        //#define CLI_IN_SVR_FIREWALL_KW "cliInSvrFirewall" /* cli behind same firewall */
        //#define REG_CHKSUM_KW	"regChksum" 	/* register checksum */
        //#define VERIFY_CHKSUM_KW "verifyChksum"	/* verify checksum */
        //#define VERIFY_BY_SIZE_KW "verifyBySize" /* verify by size - used by irsync */
        //#define OBJ_PATH_KW	"objPath"	/* logical path of the object */ 
        //#define RESC_NAME_KW	"rescName"	/* resource name */
        //#define DEST_RESC_NAME_KW	"destRescName"	/* destination resource name */
        //#define DEF_RESC_NAME_KW	"defRescName"	/* default resource name */
        //#define BACKUP_RESC_NAME_KW "backupRescName" /* destination resource name */
        //#define DATA_TYPE_KW	"dataType"	/* data type */
        //#define DATA_SIZE_KW	"dataSize"
        //#define CHKSUM_KW	"chksum"
        //#define VERSION_KW	"version"
        //#define FILE_PATH_KW	"filePath"	/* the physical file path */
        //#define REPL_NUM_KW	"replNum"	/* replica number */
        //#define WRITE_FLAG_KW	"writeFlag"	/* whether it is opened for write */
        //#define REPL_STATUS_KW	"replStatus"	/* status of the replica */
        //#define ALL_REPL_STATUS_KW	"allReplStatus"	/* update all replStatus */
        //#define DATA_INCLUDED_KW "dataIncluded"	/* data included in the input buffer */
        //#define DATA_OWNER_KW	"dataOwner"	
        //#define DATA_OWNER_ZONE_KW	"dataOwnerZone" 
        //#define DATA_EXPIRY_KW	"dataExpiry"
        //#define DATA_COMMENTS_KW "dataComments"
        //#define DATA_CREATE_KW	"dataCreate"
        //#define DATA_MODIFY_KW	"dataModify"
        //#define DATA_ACCESS_KW	"dataAccess"
        //#define DATA_ACCESS_INX_KW	"dataAccessInx"
        //#define NO_OPEN_FLAG_KW	"noOpenFlag"
        //#define PHYOPEN_BY_SIZE_KW "phyOpenBySize"
        //#define STREAMING_KW	"streaming"
        //#define DATA_ID_KW     "dataId"
        //#define COLL_ID_KW     "collId"
        //#define RESC_GROUP_NAME_KW     "rescGroupName"
        //#define DATA_MODE_KW   "dataMode"
        //#define STATUS_STRING_KW     "statusString"
        //#define DATA_MAP_ID_KW    "dataMapId"
        //#define RESC_ZONE_KW      "zoneName"
        //#define RESC_LOC_KW 	"rescLoc"   /* resc_net in DB */
        //#define RESC_TYPE_KW 	"rescType"
        //#define RESC_CLASS_KW	"rescClass"
        //#define RESC_VAULT_PATH_KW	"rescVaultPath" /* resc_def_path in DB */
        //#define RESC_STATUS_KW	"rescStatus"
        //#define PARA_OPR_KW	"paraOpr"
        //#define GATEWAY_ADDR_KW	"gateWayAddr"   
        //#define RESC_MAX_OBJ_SIZE_KW "rescMaxObjSize"
        //#define FREE_SPACE_KW	"freeSpace"
        //#define FREE_SPACE_TIME_KW	"freeSpaceTime"
        //#define FREE_SPACE_TIMESTAMP_KW	"freeSpaceTimeStamp"
        //#define RESC_TYPE_INX_KW 	"rescTypeInx"
        //#define RESC_CLASS_INX_KW	"rescClassInx"
        //#define RESC_ID_KW	"rescId"
        //#define RESC_INFO_KW     "rescInfo"
        //#define RESC_COMMENTS_KW     "rescComments"
        //#define RESC_CREATE_KW     "rescCreate"
        //#define RESC_MODIFY_KW     "rescModify"

    }
}
